class Solution {
public:
    string addStrings(string num1, string num2) {
        string s;
        int size1 = num1.size() - 1, size2 = num2.size() - 1;
        int next = 0;
        while (size1 >= 0 || size2 >= 0)
        {
            int a = size1 >= 0 ? num1[size1] - '0' : 0;
            int b = size2 >= 0 ? num2[size2] - '0' : 0;
            char ret = (a + b + next) % 10 + '0';
            next = (a + b + next) / 10;
            s.push_back(ret);
            size1--;
            size2--;
        }
        if (next == 1)
        {
            s.push_back('1');
        }
        reverse(s.begin(), s.end());
        return s;
    }
};